package com.zrwl.poscloud.core.restapi.admin.baseInfo;
import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.core.annotion.OperationLogger.OperationLogger;
import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.Delete;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.commons.validator.group.Insert;
import com.zrwl.poscloud.commons.validator.group.Update;
import com.zrwl.poscloud.xo.service.AdminService;
import com.zrwl.poscloud.xo.vo.AdminVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zrwl.poscloud.xo.service.UserServiceOrderHandleService;
import com.zrwl.poscloud.xo.vo.UserServiceOrderHandleVO;
/**
 * 服务订单处理 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-05-23
 */
@RestController
@Api(value = "服务订单处理相关接口", tags = {"服务订单处理相关接口"})
@RequestMapping("/userServiceOrderHandle")
@Slf4j
public class UserServiceOrderHandleRestApi {
    @Autowired
    private AdminService adminService;
    @Autowired
    private UserServiceOrderHandleService userServiceOrderHandleService;
    @AuthorityVerify
    @ApiOperation(value = "获取服务订单处理列表", notes = "获取服务订单处理列表", response = String.class)
    @PostMapping("/getList")
    public String getList(@Validated({GetList.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取服务订单处理列表: {}", userServiceOrderHandleVO);
        return ResultUtil.successWithData(userServiceOrderHandleService.getPageList(userServiceOrderHandleVO));
    }

    @AuthorityVerify
    @ApiOperation(value = "获取服务订单处理列表", notes = "获取服务订单处理列表", response = String.class)
    @PostMapping("/getAllList")
    public String getAllList(@Validated({GetList.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取服务订单处理列表: {}", userServiceOrderHandleVO);
        return ResultUtil.successWithData(userServiceOrderHandleService.getAllList(userServiceOrderHandleVO));
    }

    @AuthorityVerify
    @OperationLogger(value = "新增服务订单处理")    @ApiOperation(value = "新增服务订单处理", notes = "新增服务订单处理", response = String.class)
    @PostMapping("/add")
    public String add(@Validated({Insert.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("新增服务订单处理: {}", userServiceOrderHandleVO);
        AdminVO adminVO = adminService.getMe();
        userServiceOrderHandleVO.setAdminUid(adminVO.getUid());
        return userServiceOrderHandleService.add(userServiceOrderHandleVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "修改服务订单处理")    @ApiOperation(value = "修改服务订单处理", notes = "修改服务订单处理", response = String.class)
    @PostMapping("/edit")
    public String edit(@Validated({Update.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("修改服务订单处理: {}", userServiceOrderHandleVO);
        return userServiceOrderHandleService.edit(userServiceOrderHandleVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "删除服务订单处理")    @ApiOperation(value = "删除服务订单处理", notes = "删除服务订单处理", response = String.class)
    @PostMapping("/delete")
    public String delete(@Validated({Delete.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("删除服务订单处理: {}", userServiceOrderHandleVO);
        return userServiceOrderHandleService.delete(userServiceOrderHandleVO);
    }

    @AuthorityVerify
    @ApiOperation(value = "获取服务订单处理列表", notes = "获取服务订单处理列表", response = String.class)
    @PostMapping("/getRefundOrderList")
    public String getRefundOrderList(@Validated({GetList.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取服务订单处理列表: {}", userServiceOrderHandleVO);
        return ResultUtil.successWithData(userServiceOrderHandleService.getRefundOrderList(userServiceOrderHandleVO));
    }

    @AuthorityVerify
    @ApiOperation(value = "获取服务订单处理列表", notes = "获取服务订单处理列表", response = String.class)
    @PostMapping("/getOrderListByDay")
    public String getOrderListByDay(@Validated({GetList.class}) @RequestBody UserServiceOrderHandleVO userServiceOrderHandleVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取服务订单处理列表: {}", userServiceOrderHandleVO);
        return ResultUtil.successWithData(userServiceOrderHandleService.getOrderListByDay(userServiceOrderHandleVO));
    }
}
